import appApi from '@/sheep/api/app';
import { defineStore } from 'pinia';
import $platform from '@/sheep/platform';
import $router from '@/sheep/router';
import user from './user';
import sys from './sys';
import { clone } from 'lodash';
const accountInfo = uni.getAccountInfoSync();
const isRelease = accountInfo.miniProgram.envVersion === 'release';
const app = defineStore({
  id: 'app',
  state: () => ({
    info: {
      // 应用信息
      name: '星品购',
      logo: '', // logo
      version: '1.1.1', // 版本号
      cdnurl: '', // 云存储域名
      filesystem: '', // 云存储平台
      user_protocol: {}, // 用户协议
      privacy_protocol: {}, // 隐私协议
      about_us: {}, // 关于我们
      copyright: '', // 版权信息 I
      copytime: '', // 版权信息 II
    },
    platform: {
      payment: [], // 支持的支付方式
      recharge_payment: [], // 支持的充值支付方式
      share: {
        methods: ['poster', 'link'],
        linkAddress: '',
        posterInfo: {},
        loginModal: {},
      },
      auto_login: 0, // 自动登陆
      bind_mobile: 0, // 登陆后绑定手机号提醒 (弱提醒，可手动关闭)
      bind: {
        wechat: false,
        mobile: false,
      },
    },
    chat: {
      room: {},
      msg: {},
      source: {},
    },
    template: {
      // 店铺装修模板
      basic: {}, // 基本信息
      home: {
        // 首页模板
        style: {},
        data: [],
      },
      user: {
        // 个人中心模板
        style: {},
        data: [],
      },
    },
    shareInfo: {}, // 全局分享信息
    authInfo: null,
    live: {
      room: {},
      msg: {},
    },
  }),
  actions: {
    // 获取Shopro应用配置和模板
    async init(templateId = null) {
      
      await new Promise(resolve => setTimeout(resolve, 100));
      
      const res = {
        "error": 0,
        "msg": "初始化",
        "data": {
          "app": {
            "name": "cbkj",
            "logo": "\/static\/img\/shop\/logo.png",
            "version": "1.1.13",
            "user_protocol": {
              "title": "用户协议",
              "id": "1"
            },
            "privacy_protocol": {
              "title": "隐私协议",
              "id": "2"
            },
            "about_us": {
              "title": "关于我们",
              "id": "3"
            },
            "copyright": "XXX有限公司版权所有",
            "copytime": "Copyright© 2018-2030"
          },
          "platform": {
            "auto_login": 0,
            "bind_mobile": 0,
            "payment": [
              "money",
              "alipay",
              "wechat",
              "offline"
            ],
            "recharge_payment": [
              "wechat",
              "alipay"
            ],
            "share": {
              "methods": [
                "poster",
                "link"
              ],
              "linkAddress": "https:\/\/mall.ichengle.top\/uni\/#\/",
              "posterInfo": {
                "user_bg": "\/static\/img\/shop\/config\/user-poster-bg.png",
                "goods_bg": "\/static\/img\/shop\/config\/goods-poster-bg.png",
                "groupon_bg": "\/static\/img\/shop\/config\/groupon-poster-bg.png"
              },
              "loginModal": {
                "bg": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/bg/bg2.png",
                "mode": "logo"
              }
            },
            "bind": {
              "wechat": false,
              "mobile": false
            }
          },
          "template": {
            "basic": {
              "tabbar": {
                "mode": 2,
                "layout": 1,
                "inactiveColor": "#8C8C8C",
                "activeColor": "#FF7A0C",
                "list": [
                  {
                    "inactiveIcon": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/home.png",
                    "activeIcon": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/home.gif",
                    "url": "/pages/index/index",
                    "text": "首页"
                  },
                  {
                    "inactiveIcon": "https://cbkj2.oss-rg-china-mainland.aliyuncs.com/2025/07/05055ed231049c40eab60ef08c6ba9d49afenlei.png",
                    "activeIcon": "https://cbkj2.oss-rg-china-mainland.aliyuncs.com/2025/07/057863c124d58b4497bb84c93f6d13a4adfenlei2.png",
                    "url": "/pages/index/category",
                    "text": "分类"
                  },
                  {
                    "inactiveIcon": "https://cbkj2.oss-rg-china-mainland.aliyuncs.com/2025/07/0518319f552c3d409494f79fac8b1e2eebfabu.png",
                    "activeIcon": "https://cbkj2.oss-rg-china-mainland.aliyuncs.com/2025/07/0518319f552c3d409494f79fac8b1e2eebfabu.png",
                    "url": "/pages/publish/index",
                    "text": "发布"
                  },
                  {
                    "inactiveIcon": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/cart.png",
                    "activeIcon": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/cart.gif",
                    "url": "/pages/index/cart",
                    "text": "购物车"
                  },
                  {
                    "inactiveIcon": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/my.png",
                    "activeIcon": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/my.gif",
                    "url": "/pages/index/user",
                    "text": "我的"
                  }
                ],
                "background": {
                  "type": "color",
                  "bgColor": "#FFFFFF"
                }
              },
              "theme": "orange"
            },
            "home": {
              "data": [
                {
                  "type": "imageBanner",
                  "data": {
                    "mode": 1,
                    "indicator": 1,
                    "list": [
                      {
                        "title": "banner01",
                        "type": "image",
                        "src": "\/storage\/default\/20230110\/fb5f5d3ade8990c789217b35fba27ef8.png",
                        "poster": "",
                        "url": "\/pages\/index\/category?id=21"
                      }
                    ],
                    "space": 0
                  },
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": "#FFFFFF"
                    },
                    "marginLeft": 0,
                    "marginRight": 0,
                    "marginTop": 0,
                    "marginBottom": 10,
                    "borderRadiusTop": 0,
                    "borderRadiusBottom": 0,
                    "padding": 0
                  }
                },
                {
                  "type": "menuButton",
                  "data": {
                    "layout": 1,
                    "col": 5,
                    "row": 1,
                    "list": [
                      {
                        "src": "\/storage\/decorate\/20221115\/4a9bde33fd13459833431db72282e91c.png",
                        "title": {
                          "text": "居家生活",
                          "color": "#FFFFFF"
                        },
                        "url": "\/pages\/index\/category?id=21",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        }
                      },
                      {
                        "src": "\/storage\/decorate\/20221115\/e65f9b968d33f335cdff6b5e0befef8e.png",
                        "title": {
                          "text": "数码家电",
                          "color": "#FFFFFF"
                        },
                        "url": "\/pages\/index\/category?id=21",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        }
                      },
                      {
                        "src": "\/storage\/decorate\/20221115\/9918d064eefa8fb1fda5715db2c248ab.png",
                        "title": {
                          "text": "服饰鞋包",
                          "color": "#FFFFFF"
                        },
                        "url": "\/pages\/index\/category?id=21",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        }
                      },
                      {
                        "src": "\/storage\/decorate\/20221115\/f6c52397b662f42a29c4e0e6244b1b16.png",
                        "title": {
                          "text": "个护清洁",
                          "color": "#FFFFFF"
                        },
                        "url": "\/pages\/index\/category?id=21",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        }
                      }
                    ]
                  },
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": ""
                    },
                    "marginLeft": 0,
                    "marginRight": 0,
                    "marginTop": 0,
                    "marginBottom": 10,
                    "borderRadiusTop": 0,
                    "borderRadiusBottom": 0,
                    "padding": 0
                  }
                },
                {
                  "type": "imageCube",
                  "data": {
                    "borderRadiusTop": 8,
                    "borderRadiusBottom": 8,
                    "space": 7,
                    "list": [
                      {
                        "width": 2,
                        "height": 2,
                        "top": 0,
                        "left": 0,
                        "src": "\/storage\/decorate\/20221115\/63cbe4b8088a28a129923b65f412fcb2.png",
                        "url": "\/pages\/index\/category?id=21"
                      },
                      {
                        "width": 2,
                        "height": 1,
                        "top": 0,
                        "left": 2,
                        "src": "\/storage\/decorate\/20221115\/50e077b0a5df1c48dcd9be4e47b03324.png",
                        "url": "\/pages\/index\/category?id=21"
                      },
                      {
                        "width": 2,
                        "height": 1,
                        "top": 1,
                        "left": 2,
                        "src": "\/storage\/decorate\/20221115\/a44ee2a893e6b296efcd167fe0dc246d.png",
                        "url": "\/pages\/index\/category?id=21"
                      }
                    ]
                  },
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": ""
                    },
                    "marginLeft": 8,
                    "marginRight": 8,
                    "marginTop": 0,
                    "marginBottom": 10,
                    "borderRadiusTop": 0,
                    "borderRadiusBottom": 0,
                    "padding": 0
                  }
                },
                {
                  "type": "titleBlock",
                  "data": {
                    "src": "\/storage\/decorate\/20221115\/70845d2cb5fc68882b27ad3de9a100e0.png",
                    "location": "left",
                    "skew": 34,
                    "title": {
                      "text": "",
                      "color": "#262626",
                      "textFontSize": 16,
                      "other": []
                    },
                    "subtitle": {
                      "text": "",
                      "color": "#8c8c8c",
                      "textFontSize": 0,
                      "other": []
                    },
                    "more": {
                      "show": 0,
                      "url": "\/pages\/index\/category?id=21"
                    }
                  },
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": ""
                    },
                    "marginLeft": 8,
                    "marginRight": 8,
                    "marginTop": 0,
                    "marginBottom": 0,
                    "borderRadiusTop": 0,
                    "borderRadiusBottom": 0,
                    "padding": 0,
                    "height": 40
                  }
                },
                {
                  "type": "goodsCard",
                  "data": {
                    "mode": 3,
                    "goodsFields": {
                      "title": {
                        "show": 1,
                        "color": "#262626"
                      },
                      "subtitle": {
                        "show": 1,
                        "color": "#8C8C8C"
                      },
                      "price": {
                        "show": 1,
                        "color": "#FF3000"
                      },
                      "original_price": {
                        "show": 1,
                        "color": "#C4C4C4"
                      },
                      "sales": {
                        "show": 1,
                        "color": "#C4C4C4"
                      },
                      "stock": {
                        "show": 0,
                        "color": "#C4C4C4"
                      }
                    },
                    "buyNowStyle": {
                      "mode": 1,
                      "text": "立即购买",
                      "color1": "#FE832A",
                      "color2": "#FF6000",
                      "src": ""
                    },
                    "tagStyle": {
                      "show": 0,
                      "src": ""
                    },
                    "goodsIds": [
                      17,
                      18,
                      19
                    ],
                    "borderRadiusTop": 6,
                    "borderRadiusBottom": 6,
                    "space": 8
                  },
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": ""
                    },
                    "marginLeft": 8,
                    "marginRight": 8,
                    "marginTop": 0,
                    "marginBottom": 10,
                    "borderRadiusTop": 0,
                    "borderRadiusBottom": 0,
                    "padding": 0
                  }
                },
                {
                  "type": "titleBlock",
                  "data": {
                    "src": "\/storage\/decorate\/20221115\/ce9cb18e6cd8dda71287195d97fc5c2d.png",
                    "location": "left",
                    "skew": null,
                    "title": {
                      "text": "",
                      "color": "#262626",
                      "textFontSize": 16,
                      "other": []
                    },
                    "subtitle": {
                      "text": "",
                      "color": "#8c8c8c",
                      "textFontSize": 0,
                      "other": []
                    },
                    "more": {
                      "show": 0,
                      "url": "\/pages\/index\/category?id=21"
                    }
                  },
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": ""
                    },
                    "marginLeft": 8,
                    "marginRight": 8,
                    "marginTop": 0,
                    "marginBottom": 0,
                    "borderRadiusTop": 0,
                    "borderRadiusBottom": 0,
                    "padding": 0,
                    "height": 40
                  }
                },
                {
                  "type": "goodsCard",
                  "data": {
                    "mode": 2,
                    "goodsFields": {
                      "title": {
                        "show": 1,
                        "color": "#262626"
                      },
                      "subtitle": {
                        "show": 1,
                        "color": "#8C8C8C"
                      },
                      "price": {
                        "show": 1,
                        "color": "#FF3000"
                      },
                      "original_price": {
                        "show": 1,
                        "color": "#C4C4C4"
                      },
                      "sales": {
                        "show": 1,
                        "color": "#C4C4C4"
                      },
                      "stock": {
                        "show": 0,
                        "color": "#C4C4C4"
                      }
                    },
                    "buyNowStyle": {
                      "mode": 2,
                      "text": "立即购买",
                      "color1": "#E9B461",
                      "color2": "#EECC89",
                      "src": "\/storage\/decorate\/20221115\/4782356b4587dc4f4a218f2540a0bafc.png"
                    },
                    "tagStyle": {
                      "show": 0,
                      "src": ""
                    },
                    "goodsIds": [
                      14,
                      16,
                      12,
                      8,
                      9,
                      21
                    ],
                    "borderRadiusTop": 6,
                    "borderRadiusBottom": 6,
                    "space": 8
                  },
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": ""
                    },
                    "marginLeft": 8,
                    "marginRight": 8,
                    "marginTop": 0,
                    "marginBottom": 10,
                    "borderRadiusTop": 0,
                    "borderRadiusBottom": 0,
                    "padding": 0
                  }
                }
              ],
              "style": {
                "background": {
                  "color": "#FF9237",
                  "src": ""
                },
                "navbar": {
                  "mode": "inner",
                  "alwaysShow": 1,
                  "type": "color",
                  "color": "#EB3924",
                  "src": "",
                  "list": {
                    "mp": [
                      {
                        "width": 5,
                        "height": 1,
                        "top": 0,
                        "left": 0,
                        "type": "search",
                        "text": "",
                        "textColor": "#111111",
                        "src": "",
                        "url": "",
                        "placeholder": "输入商品搜索",
                        "borderRadius": 20
                      },
                      {
                        "width": 1,
                        "height": 1,
                        "top": 0,
                        "left": 5,
                        "type": "image",
                        "text": "",
                        "textColor": "#111111",
                        "src": "\/static\/quan.png",
                        "url": "\/pages\/coupon\/list",
                        "placeholder": "",
                        "borderRadius": 0
                      }
                    ],
                    "app": [
                      {
                        "width": 7,
                        "height": 1,
                        "top": 0,
                        "left": 0,
                        "type": "search",
                        "text": "",
                        "textColor": "#111111",
                        "src": "",
                        "url": "",
                        "placeholder": "输入商品搜索",
                        "borderRadius": 23
                      },
                      {
                        "width": 1,
                        "height": 1,
                        "top": 0,
                        "left": 7,
                        "type": "image",
                        "text": "",
                        "textColor": "#111111",
                        "src": "\/static\/quan.png",
                        "url": "\/pages\/coupon\/list",
                        "placeholder": "",
                        "borderRadius": 0
                      }
                    ]
                  }
                }
              }
            },
            "user": {
              "data": [
                {
                  "type": "userCard",
                  "style": {
                    "marginLeft": 0,
                    "marginRight": 0,
                    "marginTop": 70,
                    "marginBottom": 10,
                    "borderRadiusTop": 0,
                    "borderRadiusBottom": 0,
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": ""
                    }
                  }
                },
                {
                  "type": "orderCard",
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": "#FFFFFF"
                    },
                    "marginLeft": 10,
                    "marginRight": 10,
                    "marginTop": 0,
                    "marginBottom": 8,
                    "borderRadiusTop": 8,
                    "borderRadiusBottom": 8,
                    "padding": 0
                  }
                },
                {
                  "type": "couponCard",
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": "#FFFFFF"
                    },
                    "marginLeft": 10,
                    "marginRight": 10,
                    "marginTop": 0,
                    "marginBottom": 8,
                    "borderRadiusTop": 8,
                    "borderRadiusBottom": 8,
                    "padding": 0
                  }
                },
                // {
                //     "type": "walletCard",
                //     "style": {
                //         "background": {
                //             "type": "color",
                //             "bgImage": "",
                //             "bgColor": "#FFFFFF"
                //         },
                //         "marginLeft": 10,
                //         "marginRight": 10,
                //         "marginTop": 0,
                //         "marginBottom": 8,
                //         "borderRadiusTop": 8,
                //         "borderRadiusBottom": 8,
                //         "padding": 0
                //     }
                // },
                {
                  "type": "menuGrid",
                  "data": {
                    "col": 4,
                    "list": [
                      
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/set.png",
                        "title": {
                          "text": "清空缓存",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/public\/setting",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/star.png",
                        "title": {
                          "text": "关注",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/follow\/index",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/footprints.png",
                        "title": {
                          "text": "钱包",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/app\/integralHistory",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/star.png",
                        "title": {
                          "text": "会员充值",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/pay\/recharge",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/edit.png",
                        "title": {
                          "text": "意见反馈",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/public\/feedback",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      // {
                      //   "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/message.png",
                      //   "title": {
                      //     "text": "常见问题",
                      //     "color": "#333"
                      //   },
                      //   "tip": {
                      //     "text": "",
                      //     "color": "#bbb"
                      //   },
                      //   "url": "\/pages\/public\/richtext?key=mall.question&title=常见问题",
                      //   "badge": {
                      //     "show": 0,
                      //     "text": "",
                      //     "color": "#FFFFFF",
                      //     "bgColor": "#FF6000"
                      //   },
                      //   finish: true
                      // },
                      // {
                      //   "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/medal.png",
                      //   "title": {
                      //     "text": "积分商城",
                      //     "color": "#333"
                      //   },
                      //   "tip": {
                      //     "text": "",
                      //     "color": "#bbb"
                      //   },
                      //   "url": "\/pages\/app\/score-shop",
                      //   "badge": {
                      //     "show": 0,
                      //     "text": "",
                      //     "color": "#FFFFFF",
                      //     "bgColor": "#FF6000"
                      //   },
                      //   finish: false
                      // },
                      // {
                      //   "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/userStar.png",
                      //   "title": {
                      //     "text": "关于我们",
                      //     "color": "#333"
                      //   },
                      //   "tip": {
                      //     "text": "",
                      //     "color": "#bbb"
                      //   },
                      //   "url": "\/pages\/public\/richtext?key=mall.aboutUs&title=关于我们",
                      //   "badge": {
                      //     "show": 0,
                      //     "text": "",
                      //     "color": "#FFFFFF",
                      //     "bgColor": "#FF6000"
                      //   },
                      //   finish: true
                      // },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/privacy.png",
                        "title": {
                          "text": "隐私协议",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/public\/richtext?key=mall.privacyAgreement&title=隐私协议",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/team.png",
                        "title": {
                          "text": "我的团队",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/app\/team",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/location.png",
                        "title": {
                          "text": "收货地址",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/user\/address\/list",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/customer_service.png",
                        "title": {
                          "text": "联系客服",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/chat\/index",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      },
                      {
                        "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/icons/edit.png",
                        "title": {
                          "text": "我的发布",
                          "color": "#333"
                        },
                        "tip": {
                          "text": "",
                          "color": "#bbb"
                        },
                        "url": "\/pages\/user\/my-release",
                        "badge": {
                          "show": 0,
                          "text": "",
                          "color": "#FFFFFF",
                          "bgColor": "#FF6000"
                        },
                        finish: true
                      }
                    ]
                  },
                  "style": {
                    "background": {
                      "type": "color",
                      "bgImage": "",
                      "bgColor": "#FFFFFF"
                    },
                    "marginLeft": 10,
                    "marginRight": 10,
                    "marginTop": 0,
                    "marginBottom": 10,
                    "borderRadiusTop": 8,
                    "borderRadiusBottom": 8,
                    "padding": 0
                  }
                }
              ],
              "style": {
                "background": {
                  "color": "#F6F6F6",
                  "src": "https://git-open.oss-cn-shenzhen.aliyuncs.com/ruoyi-mall/uniapp/b530150a466c8cda0a4cd5b29e2c8d11.png"
                },
              }
            }
          },
          "chat": {
            "room_id": "admin",
            "chat_domain": "https:\/\/api.cbkj.sheepjs.com\/chat"
          }
        }
      }
      if (res.error === 0) {
        this.info = res.data.app;
        this.platform = res.data.platform;
        this.template = res.data.template;
        if (!res.data.template) {
          $router.error('TemplateError');
        }
        this.chat = res.data.chat;

        // 如果不是正式版，移除发布菜单
        if (!isRelease && this.template.basic.tabbar && this.template.basic.tabbar.list) {
          this.template.basic.tabbar.list = this.template.basic.tabbar.list.filter(item => 
            item.url !== '/pages/publish/index'
          );
        }

        // 加载主题
        const sysStore = sys();
        sysStore.setTheme();

        // 模拟用户登录
        const userStore = user();
        if (userStore.isLogin) {
          userStore.loginAfter();
        }
        return Promise.resolve(true);
      } else {
        $router.error('InitError', res.msg || '加载失败');
      }
    },
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'app-store',
      },
    ],
  },
});

export default app;
